/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package momo.impl;

import java.util.Collection;

import momo.Control;
import momo.MomoPackage;
import momo.PaintDiagram;
import momo.Simplex;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Paint Diagram</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link momo.impl.PaintDiagramImpl#getSimplices <em>Simplices</em>}</li>
 *   <li>{@link momo.impl.PaintDiagramImpl#getControl <em>Control</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PaintDiagramImpl extends EObjectImpl implements PaintDiagram {
	/**
	 * The cached value of the '{@link #getSimplices() <em>Simplices</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSimplices()
	 * @generated
	 * @ordered
	 */
	protected EList<Simplex> simplices;

	/**
	 * The cached value of the '{@link #getControl() <em>Control</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getControl()
	 * @generated
	 * @ordered
	 */
	protected Control control;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PaintDiagramImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MomoPackage.Literals.PAINT_DIAGRAM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Simplex> getSimplices() {
		if (simplices == null) {
			simplices = new EObjectResolvingEList<Simplex>(Simplex.class, this, MomoPackage.PAINT_DIAGRAM__SIMPLICES);
		}
		return simplices;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Control getControl() {
		if (control != null && control.eIsProxy()) {
			InternalEObject oldControl = (InternalEObject)control;
			control = (Control)eResolveProxy(oldControl);
			if (control != oldControl) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MomoPackage.PAINT_DIAGRAM__CONTROL, oldControl, control));
			}
		}
		return control;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Control basicGetControl() {
		return control;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setControl(Control newControl) {
		Control oldControl = control;
		control = newControl;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.PAINT_DIAGRAM__CONTROL, oldControl, control));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MomoPackage.PAINT_DIAGRAM__SIMPLICES:
				return getSimplices();
			case MomoPackage.PAINT_DIAGRAM__CONTROL:
				if (resolve) return getControl();
				return basicGetControl();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MomoPackage.PAINT_DIAGRAM__SIMPLICES:
				getSimplices().clear();
				getSimplices().addAll((Collection<? extends Simplex>)newValue);
				return;
			case MomoPackage.PAINT_DIAGRAM__CONTROL:
				setControl((Control)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MomoPackage.PAINT_DIAGRAM__SIMPLICES:
				getSimplices().clear();
				return;
			case MomoPackage.PAINT_DIAGRAM__CONTROL:
				setControl((Control)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MomoPackage.PAINT_DIAGRAM__SIMPLICES:
				return simplices != null && !simplices.isEmpty();
			case MomoPackage.PAINT_DIAGRAM__CONTROL:
				return control != null;
		}
		return super.eIsSet(featureID);
	}

} //PaintDiagramImpl
